Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

384
Vistas
How to hide buttons based on your "job"?

I am creating an app and I want that the buttons appear based on your $job. There are 4 jobs, which are all in mysql databases:

  1. student
  2. teacher
  3. staff
  4. principal,

The signup button can only be seen by teacher, staff and principal.

But I don't know how to do it.

Here is my code:

<?php
   session_start();

   include("connection.php");
   include("functions.php");

   $user_data = check_login($con);

   if ($_SERVER['REQUEST_METHOD'] == "POST") {
       $job = $_POST['job'];
   }
?>


<!DOCTYPE html>
<html>
<head>
    <title> NetPlat </title>
</head>
<body>
    <a href="login.php">
        <button id="button">Logout</button>
    </a><br><br>
    <a href="signup.php">
        <button>Signup Student</button>
    </a>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Surrounding the button markup with a simple if statement using the in_array function to check that the job is allowed, will work.

<?php
if(in_array($job, ['teacher', 'staff', 'principal']))
{
?>
    <a href="signup.php">
        <button>Signup Student</button>
    </a>
<?php
}
?>

The above will only output the button html if the value of $job is found in the array.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda